<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>销售报表</title>
		<link rel="stylesheet" href="/dvmini/res/plugins/layui/css/layui.css">
		<link rel="stylesheet" href="/dvmini/res/css/basic.css">
	</head>
	<style>
	.Detailbtn .layui-form-label{
		width:90px;	
	}
	.Detailbtn .layui-input-inline{
		width:380px !important;
	}
	</style>
	<body class="wrap">
		<form class="layui-form">
			<div class="layui-form-item searchbox" style="margin-bottom: 0px;">
				<div class="layui-input-inline" style="width: 150px;">
					<input type="text" class="layui-input" name="keyword" placeholder="关键字" />
				</div>
				<button class="layui-btn" lay-submit lay-filter="querybtn">查询</button>
				<button class="layui-btn layui-btn-primary" lay-submit lay-filter="resetbtn" type="reset">重置</button>
			</div>
		</form>
		<table class="layui-table">
			<thead>
				<tr>
					<th style="width:30px;">No</th>
					<th style="min-width: 60px;">销售人员</th>
					<th style="min-width: 80px;">楼盘</th>
					<th style="min-width: 56px;">粉丝数量</th>
					<th style="min-width: 70px;">拨打电话数</th>
					<th style="min-width: 84px;">回复信息数量</th>
				</tr>
			</thead>
				
			<tbody id="salelist">
			
			</tbody>
		</table>
		<div class="nulldata">暂无数据</div>
		<div id="page"></div>
		
	</body>
	<script src='/dvmini/res/js/jquery.min.js'></script>
	<script src="/dvmini/res/plugins/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript" src="/dvmini/res/js/me.js"></script>
	<script>
		layui.use(['form', 'element', 'laydate', 'layer', 'laypage'], function() {
			var form = layui.form(),
				element = layui.element(),
				laydate = layui.laydate,
				layer = layui.layer,
				laypage = layui.laypage;
			
			var queryObj={
				page : 1,
				keyword : ""
			};
			
			initData(queryObj);

			function initData(queryObj){
				$.post("/dvmini/report/getSalesReportList",queryObj,function(data){
					console.log(data)
					data=data.data;
					
					laypage({
						cont: 'page',
						pages: data.totalPages, 
						curr: queryObj.page,
						skip: true,
						jump: function(obj, first) {
							if(!first) {
								queryObj.page = obj.curr
								initData(queryObj)
							}
						}
					});
					
					$("#salelist").html("")
					
					if(data.rows.length>0){
						$(".nulldata").hide()
						var str="";
						for(var i=0;i<data.rows.length;i++){
							str+='<tr>'
								+'<td>'+ ((data.page - 1) * data.pageSize + i + 1) +'</td>'
								+'<td>'+ data.rows[i].name +'</td>'
								+'<td>'+ data.rows[i].projectname +'</td>'
								+'<td>'+ data.rows[i].fanscount +'</td>'
								+'<td>'+ data.rows[i].callcount +'</td>'
								+'<td>'+ data.rows[i].chatcount +'</td>'
								+'</tr>'
						}
						$("#salelist").html(str)
						toNull_G();
					}else{
						$(".nulldata").show()
						return false;
					}
				})
			}
			
			//查询
			form.on("submit(querybtn)", function(e){
				queryObj.keyword=e.field.keyword;
				queryObj.page=1;
				initData(queryObj)
				return false
			})
			
			//重置
			form.on("submit(resetbtn)", function(e){
				$("[name=keyword]").val("")
				queryObj={
						page : 1,
						keyword : ""
				};
				form.render();
				initData(queryObj)
				return false
			})

		})
	</script>

</html>